<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>

</body>
<script>
//动态路由
asyncRoutes = [
  { children: [ {name: 'approvals'}]},
  { children: [ {name: 'attendances'}]},
  { children: [ {name: 'departments'}]},
  { children: [ {name: 'employees'}]},
  { children: [ {name: 'permission'}]},
  { children: [ {name: 'salarys'}]},
  { children: [ {name: 'setting'}]},
  { children: [ {name: 'social'}]}
]
//菜单标识
/*
let menus = [
    'employees',
    'settings',
    'permissions',
    'departments',
    'approvals',
    'salarys',
    'attendances',
    'social_securitys'
]
*/
let menus = [
    'employees',
    'settings',
    'permissions'
]
//目标
/*
let filterRoutes = [
  { children: [ {name: 'employees'}]},
  { children: [ {name: 'permission'}]},
  { children: [ {name: 'setting'}]},
]
*/
// let filterRoutes = asyncRoutes.filter(t=>menus.includex(t.children[0].name))
// 模糊匹配
// console.log('settings'.includes('setting'))
// 数组转字符串
// console.log(['settings','permissions'].toString())
// console.log(['settings','permissions'].join(','))
// console.log(['settings','permissions']+''())
// console.log(filterRoutes)
// 判断数组当中是否有一个满足xxx条件
// console.log(['settings','permissions'].some(t=>t.includes('setting')))

let filterRoutes = asyncRoutes.filter(t=> menus.some(m=> m.includes(t.children[0].name)))
console.log(filterRoutes)
</script>
</html>
